/*
    ModbusIP.h - Header for Modbus IP Library
    Copyright (C) 2015 André Sarmento Barbosa
*/
#include <Modbus.h>
#include "WiFi.h"
#include "ETH.h"
#ifndef MODBUSIP_H
#define MODBUSIP_H

#define MODBUSIP_PORT 502
#define MODBUSIP_MAXFRAME 200

#define TCP_KEEP_ALIVE 0
typedef void (*MBcallbackPredeal)(byte *_frame, uint16_t len);

class ModbusIP : public Modbus
{
private:
    // WiFiServer _server;
    byte _MBAP[128];

public:
    ModbusIP();
    void config();
    void task();
    void attach(MBcallbackPredeal cb) { cb_pre_deal = cb; }
    int prcess(uint8_t ch);

public:
    bool data_com;

private:
    MBcallbackPredeal cb_pre_deal;

    int state = 0;
    int mb_cnt = 0;
    int frame_cnt = 0;
    uint32_t makr1 = 0;
    uint32_t cost = 0;
                uint16_t mbap_len;

};

#endif // MODBUSIP_H
